<!-- 新闻列表 -->
<script lang="ts">
export default {
  name: "hnlqnewList",
};
</script>
<template>
    <div class="page-box h100 display-flex czbj">
        <div>
            <dxtable :headBtn="headBtn" :dataJson="dataJson" :portUrl="portUrl" :qx="qx" ref="databale"
                sonRouter="hnlqaddNew"></dxtable>
        </div>
    </div>
</template>
<script lang='ts' setup>
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, dxpost, qurl, hf } from "../../util/index";

import { h, ref, reactive } from "vue";
const props = defineProps({
    pup: { type: String },
});
const cz = qurl()
const kknmer = ref()
const kknmerb = ref()
let headBtn = [];
const databale = ref();
const initeer = () => {
    databale.value.initDataExpose();
};
const emit = defineEmits(["callBack"]);
let dataJson = reactive([
    {
        title: "新闻名称",
        key: "title",
        placeholder: "输入新闻名称",
        search: true, // 是否在搜索栏展示
        ellipsis: {
      tooltip: true
    }
    },
    {
        title: "类型",
        type: "select",
        options: [],
        width: 100,
        key: "category",
        search: true, // 是否在搜索栏展示
        render(row) {
            try {
                return kknmer.value.filter(a => a.value == row.category)[0].label
            } catch (e) {

            }
        }
    },
    {
        title: "分站",
        type: "select",
        options: [],
        width: 100,
        key: "hnsubstation",
        search: true, // 是否在搜索栏展示
        render(row) {
            try {
                return kknmerb.value.filter(a => a.value == row.hnsubstation)[0].label
            } catch (e) {

            }
        }
    },
    {
        title: "排序",
        width: 100,
        render(row) {
            row.databaseName = "hjlqlist";
            return h(sort, {
                row,
                onCallBack: () => {
                    initeer();
                },
            });
        },
    },
    {
        title: "创建时间",
        key: "addTime",
        width: "200",
        type: "daterange",
    },
]);
let portUrl = "hnlq/hjlqlist";
if(cz.Host){ 
    portUrl = "hnlq/hjlqlist?Host="+cz.Host
}
const qx = {
    DeletePermissionID: "hnlqnewListdel", //删除
    EditPermissionIdentifier: "hnlqnewListbj", // 编辑
    NewPermissionIdentifier: "hnlqnewListxz", // 新建
    ViewPermissionID: "hnlqnewListck", // 查看
};


let pupVal = props.pup;
if (pupVal) {
    headBtn = [
        {
            name: "确认选择 ",
            async clickFun(row) {
                const arrList = row.join(",");
                emit("callBack", arrList);
            },
        },
    ];
}


const getlm = async () => {
    const { data }: any = await dxget("hnlq/api/getzdf", { name: "hncategory" })
    kknmer.value = data
    dataJson[1].options = data
}
const getfz = async () => {
    const { data }: any = await dxget("hnlq/api/getzdf", { name: "hnsubstation" })
    kknmerb.value = data
    dataJson[2].options = data
}
getlm()
getfz()
</script>
  
  
  